#!/bin/bash

echo "🧪 测试修复后的多模型系统"
echo "================================"

if [ ! -f "bin/cbp2make_ai" ]; then
    echo "❌ 可执行文件不存在"
    exit 1
fi

echo "1. 基本功能测试"
echo "---------------"
./bin/cbp2make_ai --version
echo "退出码: $?"

echo ""
echo "2. AI 帮助系统"
echo "---------------"
./bin/cbp2make_ai --ai-help

echo ""
echo "3. 模型列表"
echo "-----------"
./bin/cbp2make_ai --ai-models

echo ""
echo "4. 模型切换测试"
echo "---------------"
echo "切换到 DeepSeek V3:"
./bin/cbp2make_ai --ai-set-model 0 DS-V3

echo ""
echo "切换到 UESOFT Code Expert:"
./bin/cbp2make_ai --ai-set-model 1 UE-CodeExpert

echo ""
echo "查看当前模型状态:"
./bin/cbp2make_ai --ai-model-status

echo ""
echo "5. AI 功能测试（模拟模式）"
echo "-------------------------"
echo "测试AI对话（模拟响应）:"
./bin/cbp2make_ai --ai-chat "你好，请介绍一下你自己" 2>&1 | head -10

echo ""
echo "6. 传统功能验证"
echo "---------------"
cat > test_fixed.cbp << 'TESTFIXED'
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
    <Option title="Fixed Test" />
    <Build>
        <Target title="Release">
            <Option output="bin/fixed_test" />
        </Target>
    </Build>
    <Unit filename="main.cpp" />
</Project>
</CodeBlocks_project_file>
TESTFIXED

./bin/cbp2make_ai -in test_fixed.cbp 2>&1 | head -5
rm -f test_fixed.cbp makefile

echo ""
echo "================================"
echo "🎉 修复验证完成!"
echo ""
echo "📋 当前状态:"
echo "  ✅ 多模型系统框架正常"
echo "  ✅ 模型切换功能正常" 
echo "  ✅ 传统功能保持兼容"
echo "  ⚠️  AI功能为模拟模式（需要安装curl）"
echo ""
echo "🚀 下一步: 安装 curl 以获得完整AI功能"
echo "  运行: pacman -S curl"
